package mest.service.Modeling.Impl;

import mest.VO.hank.model.provider_fileModel;
import mest.dao.Modeling.IprovideFileDao;
import mest.entity.model_file;
import mest.entity.provider_file;
import mest.service.Modeling.IprovideFileService;
import mest.util.ResultObj;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Description
 * @auther Machenike
 * @create 2019-11-16 0:11
 */

@Service
public class provideFileServiceImpl implements IprovideFileService {

    @Resource
    private IprovideFileDao ipfd;

    @Override
    public ResultObj insertProvideFile(provider_file pf,String theirDb)   {
        try {
            int i = ipfd.insertProvideFile(pf, theirDb);
            if (i > 0) {
                return  ResultObj.createSuccessMsg(ResultObj.INSERT_SUCCESS);
            }
        } catch (Exception e) {
            e.printStackTrace();
            if (e.getClass().getName().equals("org.springframework.dao.DuplicateKeyException")) {
                return ResultObj.createErrorMsg("编码重复");
            }
            return ResultObj.createErrorMsg(ResultObj.ERROR);
        }
        return ResultObj.createErrorMsg(ResultObj.ERROR);
    }


    @Override
    public int selectCount(String theirDb) {
        return ipfd.selectCount(theirDb);
    }

    @Override
    public List<provider_file> findProvideFilePage(int index, int pageSize,String theirDb) {
        return ipfd.findProvideFilePage((index-1)*pageSize,pageSize,theirDb);
    }

    @Override
    public int delModel(Integer id,String theirDb) {
        return ipfd.delModel(id,theirDb);
    }

    @Override
    public List<provider_fileModel> queryAll(Integer index, Integer pageSize, String record,String theirDb) {
        return ipfd.queryAllModel((index-1)*pageSize,pageSize , record, theirDb);
    }

    @Override
    public int findCount(String record,String theirDb) {
        return ipfd.findCount(record,theirDb);
    }

    @Override
    public int updateByOne(provider_file record,String theirDb) {
        return ipfd.updateByPrimaryKeySelective(record,theirDb);
    }



}
